﻿package com.wandian.view.mediator.shop
{
	import com.wandian.controller.AccountCommand;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.SwfDataProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.model.vo.VIPVo;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZLlistScrollPanel;
	import com.wandian.util.CLZLoadIcon;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.GolbalTimer;
	import com.wandian.util.RadioManage;
	import com.wandian.view.components.ui.AddBtn;
	import com.wandian.view.components.ui.GiveGiftPlayer;
	import com.wandian.view.components.ui.MaskTipPanel;
	import com.wandian.view.components.ui.PropGiftInfo;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.mediator.*;

    public class ShopVipMediator extends Mediator
    {
        private var _arrListMc:Array;
        private var _global:GameData;
        private var _onPlayerVo:PlayerVo;
        public static const NAME:String = "ShopVipMediator";

        public function ShopVipMediator(param1:MovieClip, param2:PlayerVo)
        {
            this._global = GameData.getInstance();
            this._onPlayerVo = param2;
            super(NAME, param1);
            return;
        }

        override public function onRegister() : void
        {
            this.sendNotification(CLZNoticeName.SHOP_VIP_LIST_REQ);
            return;
        }

        private function showVIPList(param1:Array) : void
        {
            var _loc_5:VIPVo = null;
            var _loc_6:MovieClip = null;
            var _loc_7:String = null;
            if (param1 != null)
            {
            }
            if (param1.length == 0)
            {
                return;
            }
            var _loc_2:* = new CLZLlistScrollPanel(1, 727, 97, 0, 10, 445 - 37, 734, 0);
            this.mcVIP.addChild(_loc_2);
            _loc_2.x = 15;
            _loc_2.y = 47;
            this.mcVIP.vipTip_mc.txt.text = GameData.tip["PAY_PANEL_TIP_TXT_1"];
            var _loc_3:* = param1.length;
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3)
            {
                
                _loc_5 = GameData.getVIPXMLById(param1[_loc_4]);
                _loc_6 = GameData.getMovieClip("VipInfoMc");
                _loc_2.setMc(_loc_6, _loc_4, _loc_3);
                if (this._global.userInfo.userVo.gp != GameData.QZONE_SID)
                {
                }
                if (this._global.userInfo.userVo.gp == GameData.FRIEND_SID)
                {
                    _loc_6["txt9"].htmlText = GameData.replaceStrValue(GameData.tip["VIP_NUM_PRICE_Q"], "NUM", _loc_5.cost * 10);
                    _loc_6["txt10"].htmlText = GameData.tip["YELLOW_SHOW_TIP"];
                    _loc_6["yellowSign_mc"].visible = true;
                }
                else
                {
                    _loc_6["txt10"].htmlText = "";
                    _loc_6["yellowSign_mc"].visible = false;
                    _loc_6["txt9"].htmlText = GameData.replaceStrValue(GameData.tip["VIP_NUM_PRICE"], "NUM", _loc_5.cost);
                }
                if (_loc_5.objContent["1"] != null)
                {
                    if (_loc_5.objContent["2"] != null)
                    {
                        _loc_6["txt1"].htmlText = "◈ " + GameData.replaceStrValue(GameData.replaceStrValue(GameData.tip["VIP_LIST_FLAG_SEND_GOLD"], "NUM", _loc_5.objContent["1"]), "NUM1", _loc_5.objContent["2"]);
                    }
                    else
                    {
                        _loc_6["txt1"].htmlText = "◈ " + GameData.replaceStrValue(GameData.tip["VIP_LIST_FLAG_GET_GOLD"], "NUM", _loc_5.objContent["1"]);
                    }
                }
                for (_loc_7 in _loc_5.objContent)
                {
                    
                    switch(int(_loc_7))
                    {
                        case 3:
                        {
                            _loc_6["txt2"].htmlText = "◈ " + GameData.replaceStrValue(GameData.tip["VIP_LIST_FLAG_3"], "NUM", _loc_5.objContent[_loc_7]);
                            break;
                        }
                        case 4:
                        {
                            _loc_6["txt4"].htmlText = "◈ " + GameData.replaceStrValue(GameData.tip["VIP_ONLINE_REWARD_NUM"], "NUM", _loc_5.objContent[_loc_7]);
                            break;
                        }
                        case 5:
                        {
                            _loc_6["txt3"].htmlText = "◈ " + GameData.replaceStrValue(GameData.tip["VIP_LIST_FLAG_VIP_SIGN"], "NUM", _loc_5.id - 2);
                            break;
                        }
                        case 6:
                        {
                            break;
                        }
                        case 7:
                        {
                            _loc_6["txt5"].htmlText = "◈ " + GameData.tip["VIP_LIST_FLAG_OPEN_BANK"];
                            break;
                        }
                        case 8:
                        {
                            _loc_6["txt6"].htmlText = "◈ " + GameData.tip["VIP_LIST_FLAG_BAN"];
                            break;
                        }
                        case 9:
                        {
                            _loc_6["txt7"].htmlText = "◈ " + GameData.tip["VIP_LIST_FLAG_TICK"];
                            break;
                        }
                        case 10:
                        {
                            _loc_6["txt8"].htmlText = "◈ " + GameData.replaceStrValue(GameData.tip["VIP_LIST_FLAG_TIME"], "NUM", _loc_5.objContent[_loc_7]);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                CLZLoadIcon.addIcon(_loc_6["icon"], _loc_5.img, 195, 95);
                CLZButton.setButton(_loc_6.buyIn_btn, GameData.tip["BUYIN_NAME"]);
                _loc_6.buyIn_btn.id = _loc_5.id;
                _loc_6.buyIn_btn.addEventListener(MouseEvent.CLICK, this.onBuyInVIPHandler);
                _loc_4 = _loc_4 + 1;
            }
            return;
        }

        private function onBuyInVIPHandler(event:MouseEvent) : void
        {
            var _loc_2:* = event.target as MovieClip;
//            JSFUN.payVIPNumFunc(_loc_2.id);
            return;
        }

        override public function listNotificationInterests() : Array
        {
            return [CLZNoticeName.SHOP_VIP_LIST_RES];
        }

        override public function handleNotification(param1:INotification) : void
        {
            switch(param1.getName())
            {
                case CLZNoticeName.SHOP_VIP_LIST_RES:
                {
                    this.showVIPList(param1.getBody() as Array);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        private function get mcVIP() : MovieClip
        {
            return viewComponent as MovieClip;
        }

    }
}
